﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using SVC.client;
namespace UI.Forms
{
    public partial class Area : FormBase1
    {
        //private SVC.client.shop cur = null;
        public Area()
        {
            InitializeComponent();
        }

        private void btn_new_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Area_N frm = new Area_N();
            frm.FatherRefresh = bind;
            frm.Show();
        }

        private void btn_update_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null) return;
            string id = treeList1.FocusedNode.GetValue(treeListColumn1).ToString();
            Area_U frm = new Area_U(id);
            frm.FatherRefresh = bind;
            frm.Show();

        }

        private void btn_delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null) return;
            string id = treeList1.FocusedNode.GetValue(treeListColumn1).ToString();
            string r = my.bw.AreaByAreaCode_Delete(id, my.ACID);
            if (string.IsNullOrEmpty(id))
            {
                bind("");
            }
            else
            {
                Comm.ShowErorr(r);
            }
        }

        private void shop_Load(object sender, EventArgs e)
        {
            bind("");
        }

        private void bind(string areacode)
        {
           
            treeList1.DataSource = my.bw.Area_Get("areacode", my.ACID);
            treeList1.ExpandAll();
        }

 

        private void btn_sx_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            bind("");
        }
    }
}